﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "Exam")]
    public class ExamInfo : IDetach
    {
        public ExamInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private string _title = "";
        private int _teacherid = 0;
        private int _questiontype = 0;
        private int _classid = 0;
        private DateTime _starttime = DateTime.Now;
        private DateTime _endtime = DateTime.Now;
        private int _score = 0;
        private int _yearid = 0;


        private EntityRef<ClassInfo> _classInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_classInfo", ThisKey = "ClassId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public ClassInfo ClassInfo
        {
            get { return _classInfo.Entity; }
            set { _classInfo.Entity = value; }
        }

        private EntityRef<GradeYearInfo> _gradeYearInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_gradeYearInfo", ThisKey = "YearId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public GradeYearInfo GradeYearInfo
        {
            get { return _gradeYearInfo.Entity; }
            set { _gradeYearInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string Title
        {
            set { _title = value; }
            get { return _title; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int TeacherId
        {
            set { _teacherid = value; }
            get { return _teacherid; }
        }
        /// <summary>
        /// 0无乱序1仅实体乱序2仅答案乱序3试题和答案均乱序
        /// </summary>
        [Column]
        public int QuestionType
        {
            set { _questiontype = value; }
            get { return _questiontype; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int ClassId
        {
            set { _classid = value; }
            get { return _classid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime StartTime
        {
            set { _starttime = value; }
            get { return _starttime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime EndTime
        {
            set { _endtime = value; }
            get { return _endtime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Score
        {
            set { _score = value; }
            get { return _score; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int YearId
        {
            set { _yearid = value; }
            get { return _yearid; }
        }
        #endregion Model

        public void Detach()
        {
            this._classInfo = default(EntityRef<ClassInfo>);
            this._gradeYearInfo = default(EntityRef<GradeYearInfo>);
        }
    }
}
